package com.hzhq.contract.repo;

import com.hzhq.contract.bean.entity.Contract;
import com.hzhq.contract.bean.entity.ContractTemplate;
import com.hzhq.contract.bean.entity.Depart;
import com.hzhq.contract.bean.entity.User;
import org.bson.types.ObjectId;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * @author hzhq
 * @create 2021/4/8 11:37 下午
 * @email hzhq1255@163.com
 */
@Repository
public interface ContractTemplateRepository extends MongoRepository<ContractTemplate, ObjectId> {


    Page<ContractTemplate> findAllByCreateUserAndDeleted(User applicant, Integer deleted, Pageable pageable);


    Page<ContractTemplate> findAllByDeleted(Integer deleted, Pageable pageable);

    List<ContractTemplate> findAllByDeleted(Integer deleted);

    Optional<ContractTemplate> findByTemplateIdAndDeleted(ObjectId id, Integer deleted);

    List<ContractTemplate> findByTemplateNameAndDeleted(String templateName, Integer deleted);



    Page<ContractTemplate> findByDepartAndDeleted(Depart depart, Integer deleted, Pageable pageable);


    Optional<ContractTemplate> findByTemplateNameAndDepartAndDeleted(String templateName, Depart depart, Integer deleted);

}
